package student_system.Controller;

import student_system.Dao.studentDao;
import student_system.bean.student;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/alter")
public class student_alterservlet extends HttpServlet {
    studentDao dao=new studentDao();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
        req.setCharacterEncoding("utf-8");
        String snoStr=req.getParameter("sno");
        //int sno= Integer.parseInt(snoStr);
        int sno=0;
        try {
            sno = Integer.parseInt(snoStr);
        } catch (Exception e) {
            System.out.println("error");
            //return null;
        }
        student student=dao.selectbysno(sno);

        //List<student> list=dao.testArrayList();
        req.setAttribute("lists",student);
        RequestDispatcher dispatcher =req.getRequestDispatcher("studentalter.jsp");
        dispatcher.forward(req,resp);


    }
}
